import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);
// 定义路由数组routeList
let routeList = [];
// 引入路由函数
((route) => {
  route.keys().forEach((key) => {
    routeList.push(route(key));
  });
})(require.context("./", false, /\.routes.js$/));
const routes = [
  ...routeList,
  {
    path: "/",
    name: "index",
    component: () => import(/* webpackChunkName:"index" */ "@/views/Index.vue"),
  },
  {
    path: "/upload",
    name: "/upload",
    component: () => import(/* webpackChunkName:"upload"*/"@/views/Upload")
  },
  {
    path: "/details",
    name: "details",
    component: () => import(/* webpackChunkName:"details" */"@/views/Details")
  },
  {
    path: "/all",
    name: "all",
    component: () => import(/*webpackChunkName:"all"*/"@/views/All")
  },
  {
    path: "/type",
    name: "type",
    component: () => import(/*webpackChunkName:"type"*/"@/views/Type")
  },
  {
    path: '*',
    redirect: "/"
  }
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  /*页面跳转后返回顶部*/
  scrollBehavior() {
    return {y: 0};
  },
  routes,
});


export default router;
